<?php
class Logger
{
    static private $_path = 'logs/';
    private $_log;

    static public function setLogPath($path)
    {/*{{{*/
        self::$_path = $path;
    }/*}}}*/

    static public function getBizLogger()
    {/*{{{*/
        static $ins;
        if (false == $ins instanceof self)
        {
            $ins = new self(self::$_path, 'biz');
        }
        return $ins;
    }/*}}}*/
    
    static public function getExceptionLogger()
    {/*{{{*/
        static $ins;
        if (false == $ins instanceof self)
        {
            $ins = new self(self::$_path, 'exception');
        }
        return $ins;
    }/*}}}*/
    
    static public function getSqlLogger()
    {/*{{{*/
        static $ins;
        if (false == $ins instanceof self)
        {
            $ins = new self(self::$_path, 'sql');
        }
        return $ins;
    }/*}}}*/

    private function __construct($dir, $type, $writerName='Zend_Log_Writer_Stream')
    {/*{{{*/
        if (false == class_exists($writerName))
        {
            $writerName = 'Zend_Log_Writer_Stream';
        }

        $filter = new Zend_Log_Filter_Priority(Zend_Log::DEBUG);

        $file = $dir.$type.'.'.date('Y-m-d').'.log';
        $writer = new $writerName($file);
        $writer->addFilter($filter);

        $this->_log = new Zend_Log($writer);
    }/*}}}*/

    public function __call($method, $args)
    {/*{{{*/
        $this->_log->$method($args[0]);
    }/*}}}*/
}
